import Mock from 'mockjs'
import {decrypt} from "@/utils/index";

// 登录
Mock.mock(/auth/, 'get', req => {
    return {
        code: 200,
        data: {
            id: 1,
            name: 'John',
            age: 20,
            email: 'test@test.com',
            password: 'test123'
        }
    }
})
Mock.mock(/login/g, 'post', (req) => {
    const {username, password} = JSON.parse(req.body)
    if (username === 'admin' && decrypt(password) === '123456') {
        return {
            code: 200,
            data: 'dfjsklafjdlk'
        }
    } else {
        return {
            code: 500,
            message: 'login failed'
        }
    }
})